package model.trader.portfolio;

import java.util.List;

import model.market.MarketInformation;
import model.market.MarketManager;

public class LiquidityMeasure {

	public double getTradeValueForOnePercentExpectedShift(int assetReference,MarketManager market,MarketInformation marketInfo){
		List<Double> list = marketInfo.getAssetLiquidity()[assetReference];
		double sumLiquidity = 0;
		int countLiquidity =0;
		if(market.getConfig().getTradeDelay()==market.getPeriod()){
			//AM: special portfolio construction day.
			sumLiquidity = 1000000000;
			countLiquidity=1;
		}else{
			//AM: Note this liquidity stuff is really rough.
			for(int i=list.size()-6;i<list.size();i++){
				double liquidity=list.get(i);
				if(liquidity==-1||liquidity==0){
					//No trades that day.
					//liquidity=100000;
					continue;
				}
				countLiquidity++;
				sumLiquidity+=liquidity;
				
			}
		}
		double averageLiquidity=sumLiquidity/countLiquidity;
		//System.out.println("Average liquidity = "+averageLiquidity);

		//AM: limit our exposure to % shift.
		averageLiquidity/=100;
		return averageLiquidity;
	}
	
}
